In [1]:
import sys
import os
src_path = os.path.abspath(os.path.join(os.getcwd(), "..", "src"))
if src_path not in sys.path:
sys.path.insert(0, src_path)
from plots import plot_plotly, preprocessing_results
In [2]:
# experiment 1, local epochs 3 local concept drift
local_FedCluLearn = 'results/results_FedCluLearn_2025-02-26_12_05_05.479940.txt'
global_FedCluLearn = 'results/global_model_evaluation_FedCluLearn_2025-02-26_12_05_05.479940.txt'
local_FedAtt = 'results/results_FedAtt_2025-02-26_13_25_19.867217.txt'
global_FedAtt = 'results/global_model_evaluation_FedAtt_2025-02-26_13_25_19.867217.txt'
local_FedProx = 'results/results_FedProx_2025-02-26_13_25_13.689653.txt'
global_FedProx = 'results/global_model_evaluation_FedProx_2025-02-26_13_25_13.689653.txt'
local_FedAvg = 'results/results_FedAvg_2025-02-26_13_29_55.229671.txt'
global_FedAvg = 'results/global_model_evaluation_FedAvg_2025-02-26_13_29_55.229671.txt'
local_FedCluLearn_Prox = 'results/results_FedCluLearn_Prox_2025-02-26_13_29_34.958705.txt'
global_FedCluLearn_Prox = 'results/global_model_evaluation_FedCluLearn_Prox_2025-02-26_13_29_34.958705.txt'
In [3]:
local_filenames = [local_FedCluLearn, local_FedAvg, local_FedAtt, local_FedProx, local_FedCluLearn_Prox]
global_filenames = [global_FedCluLearn, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox]
In [4]:
mse_column = 'mse'
n_rounds, y = preprocessing_results(filenames=local_filenames, mse_column=mse_column)
plot_plotly(n_rounds, y, title='Avg MSE Local models', y_axis_title=f'{mse_column.upper()} error', y_axis_max=0.3)
In [5]:
for client_id in [0,1,2]:
n_rounds, y = preprocessing_results(filenames=local_filenames, client_id=client_id, mse_column='mse')
plot_plotly(n_rounds, y, title=f'MSE Local model Client {client_id}', y_axis_title='MSE error')
In [6]:
mse_column = 'mse'
global_filenames = [global_FedCluLearn, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox]
n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column)
plot_plotly(n_rounds, y, title=f'Global model', y_axis_title=f'{mse_column.upper()}', y_axis_max=1)
In [7]:
mse_column = 'r2'
global_filenames = [global_FedCluLearn, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox]
n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column)
plot_plotly(n_rounds, y, title=f'Global model', y_axis_title=f'{mse_column.upper()}', y_axis_max=1)
In [8]:
mse_column='mse'
for client_id in [0,1,2]:
n_rounds, y = preprocessing_results(filenames=global_filenames, client_id=client_id,mse_column=mse_column)
plot_plotly(n_rounds, y, title=f'Global model - test data Client {client_id}', y_axis_title=f'{mse_column} error')
In [9]:
mse_column='r2'
for client_id in [0,1,2]:
n_rounds, y = preprocessing_results(filenames=global_filenames, client_id=client_id,mse_column=mse_column)
plot_plotly(n_rounds, y, title=f'Global model - test data Client {client_id}', y_axis_title=f'{mse_column} error')
In [10]:
mse_column='mse'
for client_id in [0,1,2]:
n_rounds, y = preprocessing_results(filenames=[local_FedCluLearn, global_FedCluLearn, None, None, None], client_id=client_id,mse_column=mse_column)
plot_plotly(n_rounds, y, title=f'Local vs Global Client {client_id}', y_axis_title=f'{mse_column} error', algo_name1='Local FedCluLearn', algo_name4='Global FedCluLearn')
In [11]:
local_FedCluLearn_070 = 'results/results_FedCluLearn_2025-03-04 10:42:21.373624.txt'
global_FedCluLearn_070 = 'results/global_model_evaluation_FedCluLearn_2025-03-04 10:42:21.373624.txt'
local_FedCluLearn_080 = 'results/results_FedCluLearn_2025-03-04 10:43:06.616600.txt'
global_FedCluLearn_080 = 'results/global_model_evaluation_FedCluLearn_2025-03-04 10:43:06.616600.txt'
local_FedCluLearn_090 = 'results/results_FedCluLearn_2025-03-04 11:28:42.427780.txt'
global_FedCluLearn_090 = 'results/global_model_evaluation_FedCluLearn_2025-03-04 11:28:42.427780.txt'
local_FedCluLearn_Prox_070 = 'results/results_FedCluLearn_Prox_2025-03-04 11:29:08.539834.txt'
global_FedCluLearn_Prox_070 = 'results/global_model_evaluation_FedCluLearn_Prox_2025-03-04 11:29:08.539834.txt'
local_FedCluLearn_Prox_080 = 'results/results_FedCluLearn_Prox_2025-03-04 11:30:23.357036.txt'
global_FedCluLearn_Prox_080 = 'results/global_model_evaluation_FedCluLearn_Prox_2025-03-04 11:30:23.357036.txt'
local_FedCluLearn_Prox_090 = 'results/results_FedCluLearn_Prox_2025-03-04 11:30:29.815623.txt'
global_FedCluLearn_Prox_090 = 'results/global_model_evaluation_FedCluLearn_Prox_2025-03-04 11:30:29.815623.txt'
In [12]:
mse_column = 'mse'
global_filenames = [global_FedCluLearn, global_FedCluLearn_070, global_FedCluLearn_080, global_FedCluLearn_090]
n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column)
plot_plotly(n_rounds, y, title=f'', y_axis_title=f'{mse_column.upper()} error', y_axis_max=1, algo_name1 = '0.5', algo_name4='0.7', algo_name5='0.8', algo_name6='0.9')
--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) Cell In[12], line 3 1 mse_column = 'mse' 2 global_filenames = [global_FedCluLearn, global_FedCluLearn_070, global_FedCluLearn_080, global_FedCluLearn_090] ----> 3 n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column) 4 plot_plotly(n_rounds, y, title=f'', y_axis_title=f'{mse_column.upper()} error', y_axis_max=1, algo_name1 = '0.5', algo_name4='0.7', algo_name5='0.8', algo_name6='0.9') File ~/git-repo/FedClust/src/plots.py:48, in preprocessing_results(filenames, client_id, mse_column) 46 n_rounds, y = __preprocessing_results_a_client(filenames, client_id, mse_column) 47 else: ---> 48 n_rounds, y = __preprocessing_results_all_clients(filenames, mse_column) 49 return n_rounds, y File ~/git-repo/FedClust/src/plots.py:55, in __preprocessing_results_all_clients(filenames, mse_column) 53 for filename in filenames: 54 if filename != None: ---> 55 dfs.append(_read_csv(filename)) 56 else: 57 dfs.append(pd.DataFrame()) File ~/git-repo/FedClust/src/plots.py:19, in _read_csv(filename) 17 fl_results_df.columns=["fl_round","client_id","learning_rate","direction","mse","best_mse","mae","r2","lookback","num_epochs","hidden_size","batch_size"] 18 else: ---> 19 raise FileNotFoundError 20 return fl_results_df FileNotFoundError: